package core.db.service.clarkGame;

import com.ddm.server.annotation.Service;
import core.db.dao.clarkGame.BaseClarkGameDao;
import core.db.entity.clarkGame.BanCityBO;
import core.db.entity.clarkGame.FamilyCityCurrencyBO;
import core.db.other.Restrictions;
import core.db.persistence.CustomerDao;
import core.db.service.BaseService;

import java.util.Objects;


@Service(source = "clark_game")
public class BanCityBOService implements BaseService<BanCityBO> {
    private BaseClarkGameDao<BanCityBO> banCityBOBaseClarkGameDao = new BaseClarkGameDao<>(BanCityBO.class);
    @Override
    public CustomerDao getDefaultDao() {
        return banCityBOBaseClarkGameDao;
    }


    @Override
    public long saveIgnoreOrUpDate(BanCityBO banCityBO) {
        BanCityBO cityBO = findOne(Restrictions.and(Restrictions.eq("value",banCityBO.getValue()),Restrictions.eq("type",banCityBO.getType())),null);
        if(Objects.nonNull(cityBO)) {
            banCityBO.setId(cityBO.getId());
            return cityBO.getId();
        } else {
            return saveIgnore(banCityBO);
        }

    }
}
